a1 = 0
a2 = 0
n=int(input())
for i in range(n):
    tmp = int(input())
    if tmp>a1:
        a2=a1
        a1=tmp
if n>2:
            print(a2)
else:
            print(a1)